import { IFeidaoAiBrowserComponent } from '@feidao/web/interfaces';
import nodejs from '@feidao/web/atom/browser/msg/nodejs';
import render from '@feidao/web/atom/browser/render/render';
import P05 from './P05';

export default async function a005(fd: IFeidaoAiBrowserComponent, ...args: any[]) {
	// 考试科目 复选框
	// 获取所有选中的复选框
	const boxs = fd.data.node.querySelectorAll('[data-feidao-name="subjects"]:checked');
	if (boxs.length === 0) {
		// 清空考场数据
		render(fd, [], P05, 'P05', 'inner');
	} else {
		// 获取考试科目编号
		const nos: string[] = [];
		Array.from(boxs).forEach((e: HTMLInputElement) => {
			const id = e.getAttribute('data-feidao-id');
			nos.push(id);
		});
		const data = await nodejs(fd.data.spaceid, 'arrange_exam_room_find', { criteria: { exam_subjects_id: { $in: nos } }, page_size: 0, page_no: 1 });
		render(fd, data, P05, 'P05', 'inner');
	}
}
